<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/template/template.xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">

	<ui:define name="title">Perfis</ui:define>

	<ui:define name="menu">
		<ui:include src="/facelets/user/user_menu.xhtml" />
	</ui:define>

	<ui:define name="content">
		<h:form>
			<p:growl id="msgs" />
			<h:inputHidden value="#{profileMB.profile.id}" />
			<p:panel id="panel" header="Perfis">
				<br />
				<p:focus for="name"></p:focus>
				<h:panelGrid columns="4" cellpadding="5">
					<label>Nome da permissão: </label>
					<p:inputText id="name" title="Nome da permissão"
						validator="#{profileMB.validateName}"
						requiredMessage="É necessário preencher o nome da permissão!"
						value="#{profileMB.profile.name}" required="true" />
				</h:panelGrid>

				<br />
				<p:dataTable height="600" var="permission" value="#{profileMB.permissions}"
					paginator="true" rows="8"
					selection="#{profileMB.selectedPermissions}">

					<p:column selectionMode="multiple" />

					<p:column style="width:200px" headerText="Permissão">
						<h:outputText value="#{permission.name}" />
					</p:column>

					<p:column headerText="Descrição">
						<h:outputText value="#{permission.description}" />
					</p:column>

				</p:dataTable>

				<h:panelGrid columns="6" cellpadding="5">
					<p:commandButton value="#{x['faces.button.label.generic.reset']}"
						type="reset" title="Limpar" />
					<p:commandButton value="#{x['faces.button.label.generic.cancel']}"
						title="Cancelar" immediate="true" ajax="false"
						action="profileSearch" />
					<p:commandButton action="#{profileMB.save}" ajax="false"
						value="#{x['faces.button.label.generic.save']}" title="Salvar" />
				</h:panelGrid>

			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>